package com.scau.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scau.data.entity.ShelfApplyDO;
import com.scau.database.entity.storemanager.PassDTO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ShelfApplyMapper extends BaseMapper<ShelfApplyDO> {
    @Select("select t.id id,\n" +
            "t.store_id store_id,\n" +
            "t.bar_code bar_code,\n" +
            "t.`count` `count`,\n" +
            "t.warehouse_id warehouse_id,\n" +
            "store.`name` store_name,\n" +
            "store.address address,\n" +
            "store.leader leader,\n" +
            "commodity_info.brand brand,\n" +
            "commodity_info.`name` commodity,\n" +
            "stock.stock stock\n" +
            "FROM \n" +
            "(select *\n" +
            "FROM shelf_apply\n" +
            "WHERE warehouse_id =#{warehouseId}) as t \n" +
            "JOIN store ON t.store_id = store.id\n" +
            "JOIN stock USING(warehouse_id,bar_code)\n" +
            "JOIN commodity_info USING(bar_code)")
    public List<PassDTO> getApplies(Integer warehouseId);
}
